<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['ischecklogin']=model('core/core')->checklogin('','',true);
	$this->model('pei')->checkclerk();
	$return['setting']=$this->plugin_setting('basic');
	$return['list']=array();
	$saler = pdo_get('jy_supplier_clerk',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$depot = pdo_get('jy_supplier_depot',array('uniacid'=>$_SESSION['uniacid'],'id'=>$saler['depot_id']));
	$member = pdo_get('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$saler['mid']),array('nickname','avatar'));
	$return['saler']=$saler;
	$return['member']=$member;
	$return['depot']=$depot;
	set_html('title','签到入库');
	exi($return);
}
if($_RQ['op']=='up'){
	$this->model('pei')->checkclerk();
	$logid=$_RQ['id'];
	$merchid=$_RQ['merchid'];	
	if($logid){
		$log=pdo_get('jy_supplier_log',array('id'=>$logid,'uniacid'=>$_SESSION['uniacid']));
	}elseif($merchid){
		$log=pdo_get('jy_supplier_log',array('status'=>0,'merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid']));
	}
	if (empty($log)) {
		exi('不存在待入库单，不能签到!','error','jy_supplier/signlog/');
	}
	$log['goods']=json_decode($log['goods'],true);
	foreach($log['goods'] as &$gv){
		$gv['unit']=pdo_getcolumn('jy_weishop_goods',array('id'=>$gv['goodsid'],'uniacid'=>$_SESSION['uniacid']),'unit');
		$gv['image']=pdo_getcolumn('jy_weishop_goods',array('id'=>$gv['goodsid'],'uniacid'=>$_SESSION['uniacid']),'image');
	}
	$return['post']=array(
		'logid'=>$log['id'],
	);
	$return['merch']=pdo_get('jy_supplier_user',array('id'=>$log['merchid'],'uniacid'=>$_SESSION['uniacid']));
	$return['log']=$log;
	$return['order_goods']=$log['goods'];
	set_html('title','核销详情');
    exi($return);
}

if($_RQ['op']=='post'){
	$post=get_postdata();
	$logid=intval($post['logid']);
	$this->model('pei')->self_verify($logid,$_SESSION['uid']);
	exi('签到成功','','jy_supplier/signlog/');
}